package chat;

import java.util.Observable;
import java.util.Observer;

import networkedmodules.Module;

public class ChatModule extends Module implements Observer
{
    ChatModel model;

    public ChatModule(ChatModel model)
    {
        this.model = model;
        model.addObserver(this);
    }

    public void addMessage(Message m)
    {
        model.addMessage(m);
    }

    public void update(Observable arg0, Object arg1)
    {
        if (arg1 instanceof Message)
        {
            this.getModuleGroup().sendUpdate(
                    new MessageUpdate((Message) arg1, this.getKey()));
        }
    }

}
